#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	long long n,l,r;
	cin>>n>>l>>r;
	long long p=l%n;
	if(r-l>(n-p-1))
	{
		p=n-1;
	}
	else
	{
		p+=r-l;
	}
	cout<<p;
}
